package com.tianji.remark.task;

import com.tianji.remark.service.ILikedRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
public class Redis2MysqlTask {
    private final static  List<String> bizTypes = List.of("QA","NOTE");
    private static final int MAX_BIZ_SIZE = 30;
    private final ILikedRecordService recordService;
    //每分钟同步一次
    @Scheduled(cron = "0 0/1 * * * ?")
    public void syncLikedTimes(){
        for (String bizType : bizTypes) {
            recordService.readLikedTimesAndSendMessage(bizType, MAX_BIZ_SIZE);
        }
    }

/*    @Scheduled(cron = "0/30 * * * * ?")
    public void syncLikedRecord(){
        recordService.readLikedRecordAndSendMessage();
    }*/
}
